# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.CloudIdentity.V1.Model.MemberRestriction do
  @moduledoc """
  The definition of MemberRestriction

  ## Attributes

  *   `evaluation` (*type:* `GoogleApi.CloudIdentity.V1.Model.RestrictionEvaluation.t`, *default:* `nil`) - The evaluated state of this restriction on a group.
  *   `query` (*type:* `String.t`, *default:* `nil`) - Member Restriction as defined by CEL expression. Supported restrictions are: `member.customer_id` and `member.type`. Valid values for `member.type` are `1`, `2` and `3`. They correspond to USER, SERVICE_ACCOUNT, and GROUP respectively. The value for `member.customer_id` only supports `groupCustomerId()` currently which means the customer id of the group will be used for restriction. Supported operators are `&&`, `||` and `==`, corresponding to AND, OR, and EQUAL. Examples: Allow only service accounts of given customer to be members. `member.type == 2 && member.customer_id == groupCustomerId()` Allow only users or groups to be members. `member.type == 1 || member.type == 3`
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :evaluation => GoogleApi.CloudIdentity.V1.Model.RestrictionEvaluation.t() | nil,
          :query => String.t() | nil
        }

  field(:evaluation, as: GoogleApi.CloudIdentity.V1.Model.RestrictionEvaluation)
  field(:query)
end

defimpl Poison.Decoder, for: GoogleApi.CloudIdentity.V1.Model.MemberRestriction do
  def decode(value, options) do
    GoogleApi.CloudIdentity.V1.Model.MemberRestriction.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.CloudIdentity.V1.Model.MemberRestriction do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
